package com.sh.rpc.fault.retry;

import com.sh.rpc.spi.SpiLoader;

/**
 * 重试工厂
 *
 * @author SH
 */
public class RetryStrategyFactory {

    static {
        SpiLoader.load(RetryStrategy.class);
    }

    /**
     * 默认重试策略
     */
    private static final RetryStrategy DEFAULT_RETRY_STRATEGY = new NoRetryStrategy();


    /**
     * 获取重试策略
     */
    public static RetryStrategy getInstance(String key) {
        RetryStrategy instance = SpiLoader.getInstance(RetryStrategy.class, key);
        return instance == null ? DEFAULT_RETRY_STRATEGY : instance;
    }
}
